home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
assemblr
/
library
/
screen
/
hercules
/
ring.asm
< prev
next >
Wrap
Assembly Source File
|
1989-10-15
|
8KB
|
229 lines
COMMENT *
Name : RING.ASM
Comment : Program to ring the speaker
Syntax : RING [ ON | OFF ]
Author : M. Bokhorst
Date : January 20th, 1988
Version : 1.0
*
;=============================================================================+
; |
; Constants Constants Constants Constants Constants Constants |
; |
;=============================================================================+
version EQU 10h ;Version number in octets
lf EQU 10 ;Linefeed character code
cr EQU 13 ;Carriage return character code
false EQU 0 ;Boolean value false
true EQU 1 ;Boolean value true
farjump EQU 0EAh ;Opcode far jump
clockint EQU 1Ch ;Interrupt# clock tick
dos EQU 21h ;Interrupt# dos services
display EQU 09h ;Function# display string
keep EQU 31h ;Function# terminate & stay resident
setint EQU 25h ;Function# set interrupt vector
getint EQU 35h ;Function# get interrupt vector
terminate EQU 4Ch ;Function# terminate process
intint EQU 0FEh ;Pointer to signature
modemstatus EQU 02FEh ;Modem status register port
RI EQU 40h ;Mask Ring Indicator
D5 EQU 2036 ;Timer value for note D5
G5 EQU 1526 ;Timer value for note G5
timervalue EQU 42h ;Timer value register
timerctl EQU 43h ;Timer control register
portb EQU 61h ;Control port B
cmdline EQU 5Dh ;Offset to command line in PSP
;=============================================================================+
; |
; Code Code Code Code Code Code Code Code Code Code |
; |
;=============================================================================+
coder SEGMENT
ASSUME CS:coder
signature: DW 'RI' ;signature
DB version ; and version number
ringon: DB true
ringhigh: DB false
;-----------------------------------------------------------------------------+
; |
; Clockhandler Clockhandler Clockhandler Clockhandler Clockhandler |
; |
;-----------------------------------------------------------------------------+
ticker: PUSH AX
PUSH DX
CMP BYTE PTR CS:[ringon], true
JNE noring
MOV DX, modemstatus
IN AL, DX
AND AL, RI ;ring signal from modem?
JZ ringoff
MOV AL, 10110110b
OUT timerctl, AL ;initialize timer
TEST BYTE PTR CS:[ringhigh], true
JNZ soundhigh
MOV AX, D5
JMP SHORT soundlow
soundhigh: MOV AX, G5
soundlow: OUT timervalue, AL ;set timer value low
MOV AL, AH
OUT timervalue, AL ;set timer value high
IN AL, portb
OR AL, 00000011b
OUT portb, AL ;switch speaker on
XOR BYTE PTR CS:[ringhigh], true
JMP SHORT noring
ringoff: IN AL, portb
AND AL, 11111100b ;switch speaker off
OUT portb, AL
MOV BYTE PTR CS:[ringhigh], false
noring: POP DX
POP AX
DB farjump
chainoff: DW ?
chainseg: DW ?
;-----------------------------------------------------------------------------+
; |
; Main Main Main Main Main Main Main Main Main Main |
; |
;-----------------------------------------------------------------------------+
main: CMP BYTE PTR DS:[cmdline], 'O' ;check command line
JNE invcmd
CMP BYTE PTR DS:[cmdline+2], ' '
JE enable
CMP BYTE PTR DS:[cmdline+1], 'F'
JNE invcmd
CMP BYTE PTR DS:[cmdline+2], 'F'
JNE invcmd
CMP BYTE PTR DS:[cmdline+3], ' '
JNE invcmd
MOV BYTE PTR CS:[ringon], false ;RING OFF
JMP SHORT instring
enable: CMP BYTE PTR DS:[cmdline+1], 'N'
JNE invcmd
MOV BYTE PTR CS:[ringon], true ;RING ON
JMP SHORT instring
invcmd: MOV AH, display
MOV DX, OFFSET strinv
PUSH CS
POP DS
INT dos ;say what's wrong
MOV AH, terminate
MOV AL, 1 ;errorlevel 1
INT dos
instring: IN AL, portb
AND AL, 11111100b
OUT portb, AL ;switch speaker off
MOV AH, getint
MOV AL, intint ;check signature
INT dos
CMP WORD PTR ES:[signature], 'RI'
JNZ notinst
CMP BYTE PTR ES:[signature+2], version
JNZ notinst
MOV AL, BYTE PTR CS:[ringon]
MOV BYTE PTR ES:[ringon], AL ;already installed: modify
MOV AH, terminate
MOV AL, 0 ;errorlevel 0
INT dos
notinst: MOV AH, getint
MOV AL, clockint
INT dos
MOV WORD PTR CS:[chainoff], BX
MOV WORD PTR CS:[chainseg], ES
MOV AH, setint
MOV AL, clockint
PUSH CS
POP DS
MOV DX, OFFSET ticker
INT dos ;setup new clock handler
MOV AH, setint
MOV AL, intint
PUSH CS
POP DS
MOV DX, OFFSET ticker
INT dos ;pointer to signature
MOV AH, display
MOV DX, OFFSET strinst ;first time install
PUSH CS
POP DS
INT dos
MOV AH, keep
MOV AL, 0 ;errorlevel 0
MOV DX, OFFSET main
MOV CL, 4
SHR DX, CL
ADD DX, 17
INT dos ;TSR
strinst:
DB 'Ring Version 1.0 installed', cr, lf, '$'
strinv:
DB cr, lf
DB 'Ring Version 1.0 ---- Syntax: RING [ ON | OFF ]', cr, lf
DB 'Written by M. Bokhorst; released January 20th, 1988', cr, lf
DB 'Questions, suggestions and bug reports to 2:512/108', cr, lf, '$'
coder ENDS
END main
;=============================================================================+
; |
; End End End End End End End End End End End End |
; |
;=============================================================================+